﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    public class CommentsDataModel
    {
        #region Hoangdx Code Comment

        HomestayWebDBEntities ent = new HomestayWebDBEntities();

        public List<Store_Comment_GetCommentsOfPost_Result> GetCommentsOfPost(int PostID)
        {
            return ent.Store_Comment_GetCommentsOfPost(PostID).ToList<Store_Comment_GetCommentsOfPost_Result>();
        }

        public void InsertComment(Comment commentDTO)
        {
            Comment CommentDB = new Comment()
            {
                Content = commentDTO.Content,
                PostID = commentDTO.PostID,
                Username = commentDTO.Username,
                TimeCreated = DateTime.Now
            };
            ent.Comments.AddObject(CommentDB);
            ent.SaveChanges();
        }

        #endregion

        public void DeleteComment(int commentId)
        {
            ent.Store_Comment_DeleteComment(commentId);
        }
    }
}
